//
//  TableView.swift
//  Box
//
//  Created by mn on 2025/3/30.
//

import UIKit

extension UITableView{
    func registerCell(_ cellType: UITableViewCell.Type) {
        registerCells([cellType])
    }
    func registerCells(_ cells: [UITableViewCell.Type]) {
        for cell in cells {
            register(cell, forCellReuseIdentifier: String(describing: cell))
        }
    }

    func cell<T>(_ indexPath: IndexPath? = nil) -> T {
        if let indexPath{
            return dequeueReusableCell(withIdentifier: String(describing: T.self), for: indexPath) as! T
        }else{
            return dequeueReusableCell(withIdentifier: String(describing: T.self)) as! T
        }
    }
}

